﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;


namespace NJL.WebUsers.Controls
{
    public partial class WUEnterPriseSpaceLeft : BaseUserControl
    {
        private readonly NJL.BLL.NJL_BOOK bllBook = new BLL.NJL_BOOK();

        private readonly NJL.BLL.NJL_COMPANY bllCompany = new BLL.NJL_COMPANY();
        private readonly NJL.BLL.NJL_COMPANY_SERVICE bllService = new BLL.NJL_COMPANY_SERVICE();
        protected NJL.Model.NJL_COMPANY modelCompany;
        public string companyid;

        protected IList<Model.NJL_COMPANY_SERVICE> LIST_COMPANY_SERVICE;
        protected ArrayList ArrayTagList = new ArrayList();
        protected IList<Model.NJL_BOOK> LIST_BOOK;

        protected void Page_Load(object sender, EventArgs e)
        {
            modelCompany = bllCompany.GetModel(Request.QueryString["id"].ToString());
            //获取订票信息
            LIST_BOOK = bllBook.GetModelList(" NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND TYPE_CODE='2' AND TARGET_ID='" + Request.QueryString["id"] + "' ");
            if (!IsPostBack)
            {

                if (modelCompany != null)
                {
                    if (modelCompany.IMAGE_CODE != "")
                    {
                        Image1.ImageUrl = GetImageUrl(modelCompany.IMAGE_CODE, "C2");
                    }
                    else
                    {
                        Image1.ImageUrl = "~/Images/defaultShopHead.jpg";
                    }

                    LIST_COMPANY_SERVICE = bllService.GetModelList("NJL_COMPANY_ID='" + modelCompany.ID + "'");

                    if (LIST_COMPANY_SERVICE != null)
                    {
                        for (int i = 0; i < LIST_COMPANY_SERVICE.Count; i++)
                        {
                            char[] charSplit = { ',' };
                            if (LIST_COMPANY_SERVICE[i].TAG != null)
                            {
                                string[] tags = LIST_COMPANY_SERVICE[i].TAG.Split(charSplit);

                                for (int j = 0; j < tags.Length; j++)
                                {
                                    if (tags[j] == "")
                                        continue;
                                    ArrayTagList.Add(tags[j]);
                                }
                            }
                        }
                    }

                    litDescription.Text = modelCompany.COMPANY_INTRO;
                }
                if (UserId != "" && UserType == "1")
                {
                    modelCompany = bllCompany.GetCompanyByUserIDModel(UserId);
                    companyid = modelCompany.ID;
                }

                if (!string.IsNullOrEmpty(modelCompany.TRAFFIC_GUIDE) && modelCompany.TRAFFIC_GUIDE.Length > 300)
                {
                    litTraffic.Text = modelCompany.TRAFFIC_GUIDE.Substring(0, 300);
                }
                else
                {
                    litTraffic.Text = modelCompany.TRAFFIC_GUIDE;
                }

            }
        }
    }

}